package com.example.sys.Service;

import com.example.sys.Entity.StudentInfo;
import com.example.sys.Mapper.StudentInfoMapper;
import com.example.sys.Vo.StudentInfoClassInfo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentInfoServiceImpl implements StudentInfoService{

    @Autowired
    private StudentInfoMapper studentInfoMapper;

    @Override
    public List<StudentInfo> getAllStudentInfo(String name) {
        return studentInfoMapper.getAllStudentInfo(name);
    }

    @Override
    public PageInfo<StudentInfoClassInfo> getPageStudentInfoClassInfo(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<StudentInfoClassInfo> allStuAndClassByName = studentInfoMapper.getAllStuAndClassByName("");
        PageInfo<StudentInfoClassInfo> pageInfo = new PageInfo<>(allStuAndClassByName);
        return pageInfo;
    }

    @Override
    public Integer  delStuById(Integer id){
        return 0;
    }

    @Override
    public List<StudentInfoClassInfo> getAllStuAndClassByName(String stuName) {

        List<StudentInfoClassInfo> stuClass = studentInfoMapper.getAllStuAndClassByName(stuName);
        return stuClass;
    }

    @Override
    public List<StudentInfoClassInfo> getAllStuAndClassByclsAndName(String stuName, Integer clsid) {
        return studentInfoMapper.getAllStuAndClassByclsAndName(stuName,clsid);
    }

    @Override
    public Integer deleteByID(Integer stuid) {
        Integer  i=studentInfoMapper.deleteByID(stuid);
        return   i;
    }

    @Override
    public Integer updateStudentInfo(StudentInfo studentInfo) {
        return studentInfoMapper.updateStudentInfo(studentInfo);
    }

    @Override
    public Integer insertStudentInfo(StudentInfo studentInfo) {
        return studentInfoMapper.insertStudentInfo(studentInfo);
    }
}
